#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef int64_t fraction_t;
#define fraction_ph PRId64

#define SET_FRACTION(VALUE, NUMERATOR, DENOMINATOR) \
    {VALUE.numerator = (NUMERATOR);VALUE.denominator = (DENOMINATOR);}

fraction_t gcd_loop(fraction_t a, fraction_t b) {
    while(b != 0) {
        fraction_t new_b = a % b;
        a = b;
        b = new_b;
    }
    return a;
}

typedef struct {
    fraction_t numerator;
    fraction_t denominator;
} fraction;

void fraction_print(fraction value) {
    if(value.denominator == 1) {
        printf("%" fraction_ph "\n", value.numerator);
    } else {
        printf("%" fraction_ph "/%" fraction_ph "\n", value.numerator, value.denominator);
    }
}

fraction fraction_reverse(fraction value) {
    fraction result;
    SET_FRACTION(result, value.denominator, value.numerator);
    return result;
}

fraction fraction_normalize(fraction value) {
    fraction result;
    if (value.numerator == 0) {
        SET_FRACTION(result, 0, 1);
    } else if (value.numerator > 0) {
        int gcd = value.denominator > value.numerator
          ? gcd_loop(value.denominator, value.numerator)
          : gcd_loop(value.numerator, value.denominator);
          SET_FRACTION(result, value.numerator / gcd, value.denominator / gcd);
    } else {
        int gcd = value.denominator > -value.numerator
          ? gcd_loop(value.denominator, -value.numerator)
          : gcd_loop(-value.numerator, value.denominator);
          SET_FRACTION(result, -value.numerator / gcd, value.denominator / gcd);
    }
    return result;
}

fraction fraction_add(fraction a, fraction b) {
    fraction_t gcd = a.denominator > b.denominator
      ? gcd_loop(a.denominator, b.denominator)
      : gcd_loop(b.denominator, a.denominator);
    fraction result;
    result.denominator = a.denominator * b.denominator / gcd;
    result.numerator = result.denominator / a.denominator * a.numerator +
      result.denominator / b.denominator * b.numerator;
    return fraction_normalize(result);
}

fraction fraction_sub(fraction a, fraction b) {
    fraction_t gcd = a.denominator > b.denominator
      ? gcd_loop(a.denominator, b.denominator)
      : gcd_loop(b.denominator, a.denominator);
    fraction result;
    result.denominator = a.denominator * b.denominator / gcd;
    result.numerator = result.denominator / a.denominator * a.numerator -
      result.denominator / b.denominator * b.numerator;
    return fraction_normalize(result);
}

fraction fraction_multiply(fraction a, fraction b) {
    fraction result;
    SET_FRACTION(result, a.numerator * b.numerator,
        a.denominator * b.denominator);
    return fraction_normalize(result);
}

fraction fraction_divide(fraction a, fraction b) {
    return fraction_multiply(a, fraction_reverse(b));
}

int main(void) {
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        int n;
        scanf("%d", &n);
        int* arr_a, *arr_b;
        arr_a = (int*) calloc(n, sizeof(int));
        arr_b = (int*) calloc(n, sizeof(int));
        
        for (int j = 0; j < n; j++) {
            scanf("%d", &arr_a[j]);
        }
        for (int j = 0; j < n; j++) {
            scanf("%d", &arr_b[j]);
        }
        
        fraction result;
        for (int j = n - 1; j >= 0; j--) {
            if (j == n - 1) {
                SET_FRACTION(result, arr_b[j], arr_a[j]);
            } else {
                fraction upper, under;
                SET_FRACTION(upper, arr_b[j], 1);
                SET_FRACTION(under, arr_a[j], 1);
                under = fraction_add(under, result);
                result = fraction_divide(upper, under);
            }
        }
        fraction_print(fraction_normalize(result));
        
        free(arr_a);
        free(arr_b);
    }
}
